class BaseIterator:

    def __init__(self,data):
        self.__data = data
    def to_begin(self):
        self.__cur_idx = -1

    def to_end(self):
        self.__cur_idx = len(self.__data)

    def next(self):
        if(self.__cur_idx <len(self.__data) -1):
            self.__cur_idx +=1
            return True
        else:
            return False

    def privious(self):
        if self.__cur_idx >0:
            self.__cur_idx-=1
            return True
        else:
            return False

    def current(self):
        return self.__data[self.__cur_idx] if self.__cur_idx<len(self.__data) and self.__cur_idx >=0 else None




if __name__ == '__main__':
    iterator  =  BaseIterator(range(0,20))
    iterator .to_begin()
    while(iterator.next()):
        customer = iterator.current()
        print(customer,end="\t")
    print()



    iterator.to_end()
    while(iterator.privious()):
        customer = iterator.current()
        print(customer,end="\t")